package com.yanqu.road.server.logic.activity.condition.rank;

import com.yanqu.road.entity.activity.ActivityConditionInfo;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.task.TaskModule;
import com.yanqu.road.server.logic.activity.BaseActivityData;
import com.yanqu.road.server.logic.activity.condition.BaseRankActivityCondition;
import com.yanqu.road.server.manger.cross3.ChannelRankActivityMgr;

import java.math.BigInteger;

/**
 * 亲密度提升冲榜 冲榜活动
 */
public class IntimacyRiseRankCondition extends BaseRankActivityCondition {

	public IntimacyRiseRankCondition(ActivityInfo activityInfo, ActivityConditionInfo activityConditionInfo, BaseActivityData baseActivityData) {
		super(activityInfo, activityConditionInfo, baseActivityData);
	}

	@Override
	public void addTrigger(GamePlayer player) {
		player.getModule(TaskModule.class).getGameEvent().addListener(eGamePlayerEventType.IntimacyRiseRank.getValue(), handle);
	}

	@Override
	public void removeTrigger(GamePlayer player) {
		player.getModule(TaskModule.class).getGameEvent().removeListener(eGamePlayerEventType.IntimacyRiseRank.getValue(), handle);
	}

	@Override
	protected void player_BoardLevelHandle(Object object) {
		int args = (int) object;
		setValue(getValue().add(BigInteger.valueOf(args)));

		if (activityInfo.getType() == eActivityType.ChannelRankActivity.getValue()) {
            ChannelRankActivityMgr.userRankChange(activityInfo.getActivityId(), activityConditionInfo.getType(), getValue().longValue(), player.getUserId(),"");
            ChannelRankActivityMgr.channelRankPartChange(activityInfo.getActivityId(), eGamePlayerEventType.ServerIntimacyRiseRank.getValue(), getValue().longValue(), player.getUserId());
        } else {
			rankChange();
		}
	}
}
